var groupManagement={
    init:function(){
        var self=this;
        self.shadeDiv = $("#shade-div");
        self.bindEvents();
        self.loadTree()
    },
    bindEvents:function(){
        var self=this;
//        全选
        $.checkAll("inputItem1")
        $.checkAll("inputItem2")
//        新增群组
        $("#newAdd").click(function(){
            self.shadeDiv.show();
            $('#addGroud').setPosition().show();

        })
//        选择用户
        $("#addMember,.addNumber").click(function(){
            self.shadeDiv.show();
            $('#addUser').setPosition().show();

        })
        $("#searchDep").textClean();
        //        搜索
        $("#searchName input").textClean()
        $("#searchName input").focus(function(){
            $(this).siblings("span").show();
        })
        $("#searchName input").blur(function(){
            if($.trim($(this).val()) == ""){
                $(this).siblings("span").hide();
            };

        })
        $(".removeSearch").click(function(){
            $(this).siblings("input").val("")
        })
        $('.searchName').keydown(function(e){
            if(e.keyCode==13){
                $(this).click(); //处理事件
            }
        });
//        注销
        $(".cancellation").click(function(){
            self.shadeDiv.show();
            $('#warning').setPosition().show().find("p.center").html("确定要注销群组吗？");

        })

//        发布群公告
        $(".announcement").click(function(){
            self.shadeDiv.show();
            $('#announcement').setPosition().show();

        })
        $(".qun").textClean();
        $(".qun1").limitWord(50,"qun1");
        $(".qun2").limitWord(200,"qun2")

        $("#findGroup").textClean();

    },
    loadTree:function(){
        $.fn.zTree.init($("#treeDemo"), setting1, zNode1);
        $.fn.zTree.init($("#treeDemo1"), setting1, zNode1);
    },
    ajaxGET:function (url, data, fn,beforeSendFn) {
        var beforeSendFn = beforeSendFn || function(){};
        $.ajax({type:"GET", dataType:'json', context:this, url:url, data:data, success:fn, beforeSend:beforeSendFn});
    },
    ajaxPOST:function (url, data, fn,beforeSendFn) {
        var beforeSendFn = beforeSendFn || function(){};
        $.ajax({type:"POST", dataType:'json', context:this, url:url, data:data, success:fn, beforeSend:beforeSendFn});
    }
}
$(function(){
    groupManagement.init()
})